package Yi.Servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import Yi.DAO.UsersDao;
import Entity.Users;
import Yi.DAO.UsersDaoFactory;


@WebServlet("/SelectServlet")
public class SelectServlet extends HttpServlet{
	private static final long serialVersionUID = 1L;
	private UsersDao UsersDao=UsersDaoFactory.createDAO();
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
	    int curpage = Integer.parseInt(request.getParameter("curpage"));
	    int pagesize = Integer.parseInt(request.getParameter("pagesize")); 
		List<Users> list = UsersDao.queryByPage(curpage, pagesize);		
		int total = UsersDao.count();
		request.setAttribute("total", total);
		request.setAttribute("list", list);	
		request.getRequestDispatcher("UserList.jsp").forward(request, response);
	}
	
}